#include <errno.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>

// Clases que encapsulan los IPCs
#include "./IPC/Semaphore/Semaphore.h"
#include "./IPC/SharedMemory/ControlDataSharedMemory.h"
#include "./IPC/MessageQueue/TruckDoorInputMessageQueue.h"
#include "./IPC/MessageQueue/TruckDoorOutputMessageQueue.h"
#include "./IPC/MessageQueue/TruckInputMessageQueue.h"
#include "./IPC/MessageQueue/TruckOutputMessageQueue.h"
#include "./IPC/MessageQueue/ChargeToTruckMessageQueue.h"



int main(int argc, char **argv) {	
	
	TruckDoorInputMessageQueue truckDoorInputQueue = TruckDoorInputMessageQueue();
	truckDoorInputQueue.getMessageQueue((char *) DIRECTORY, ID_Q_TRUCK_DOOR_INPUT);
	truckDoorInputQueue.destroy();
	
	TruckDoorOutputMessageQueue truckDoorOutputQueue = TruckDoorOutputMessageQueue();
	truckDoorOutputQueue.getMessageQueue((char *) DIRECTORY, ID_Q_TRUCK_DOOR_OUTPUT);
	truckDoorOutputQueue.destroy();
	
	TruckInputMessageQueue truckChargeInputQueue = TruckInputMessageQueue();
	truckChargeInputQueue.getMessageQueue((char *) DIRECTORY, ID_Q_TRUCK_CHARGE_INPUT);
	truckChargeInputQueue.destroy();
	
	TruckOutputMessageQueue truckChargeOutputQueue = TruckOutputMessageQueue();
	truckChargeOutputQueue.getMessageQueue((char *) DIRECTORY, ID_Q_TRUCK_CHARGE_OUTPUT);
	truckChargeOutputQueue.destroy();
	
	TruckInputMessageQueue truckDischargeInputQueue = TruckInputMessageQueue();
	truckDischargeInputQueue.getMessageQueue((char *) DIRECTORY, ID_Q_TRUCK_DISCHARGE_INPUT);
	truckDischargeInputQueue.destroy();
	
	TruckOutputMessageQueue truckDischargeOutputQueue = TruckOutputMessageQueue();
	truckDischargeOutputQueue.getMessageQueue((char *) DIRECTORY, ID_Q_TRUCK_DISCHARGE_OUTPUT);
	truckDischargeOutputQueue.destroy();
	
	ChargeToTruckMessageQueue chargeToTruckQueue = ChargeToTruckMessageQueue();
	chargeToTruckQueue.getMessageQueue((char *) DIRECTORY, ID_Q_CHARGE_TO_TRUCK);
	chargeToTruckQueue.destroy();
	
	Semaphore semControl = Semaphore();	
	semControl.getSemaphore((char *) DIRECTORY, ID_SEMCONTROL, 1);
	semControl.destroy();
	
	Semaphore semTruck = Semaphore();
	semTruck.getSemaphore((char *) DIRECTORY, ID_SEMTRUCK, CANT_TRUCKS);
	semTruck.destroy();
	
	Semaphore semTruckDoor = Semaphore();
	semTruckDoor.getSemaphore((char *) DIRECTORY, ID_SEMTRUCKDOOR, CANT_DOORS);
	semTruckDoor.destroy();

	ControlDataSharedMemory shMem = ControlDataSharedMemory();
	shMem.getSharedMemory((char *) DIRECTORY, ID_SHMEM);
	shMem.destroy();
}

